package com.ikingtech.platform.service.pay.service;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ikingtech.platform.service.pay.entity.PayRecordDO;
import com.ikingtech.platform.service.pay.mapper.PayRecordMapper;

import java.util.List;

/**
 * @author tie yan
 */
public class PayRecordService extends ServiceImpl<PayRecordMapper, PayRecordDO> {

    public List<PayRecordDO> listByRequestId(String requestId) {
        return this.list(Wrappers.<PayRecordDO>lambdaQuery()
                .eq(PayRecordDO::getRequestId, requestId)
                .orderByDesc(PayRecordDO::getUpdateTime));
    }

    public List<PayRecordDO> listByRequestIds(List<String> requestIds) {
        return this.list(Wrappers.<PayRecordDO>lambdaQuery()
                .in(PayRecordDO::getRequestId, requestIds)
                .orderByDesc(PayRecordDO::getUpdateTime));
    }

    public PayRecordDO getByRequestIdAndStatus(String requestId, Object... status) {
        return this.getOne(Wrappers.<PayRecordDO>lambdaQuery().eq(PayRecordDO::getRequestId, requestId).in(PayRecordDO::getStatus, status));
    }

    public List<PayRecordDO> listByStatus(String status) {
        return this.list(Wrappers.<PayRecordDO>lambdaQuery().eq(PayRecordDO::getStatus, status));
    }
}
